package com.spring.demo.spring_boot.mapper;

import java.util.List;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.springframework.cache.annotation.Cacheable;

import com.spring.demo.spring_boot.base.mapper.BaseMapper;
import com.spring.demo.spring_boot.domain.Role;

/**
 * 
 * @author 王辉阳
 * @date 2017年8月1日 下午6:11:28
 * @description 用户映射器
 */
@Mapper
public interface RoleMapper extends BaseMapper<Role> {
	// 查询后存入redis，建议以方法名
	@Cacheable(value = "get", keyGenerator = "keyGenerator")
	@Select("SELECT * FROM roles WHERE id = #{id}")
	Role get(@Param("id") String id);

	@Select("SELECT * FROM roles  ")
	List<Role> findAll();

	@Results(value = { //
			@Result(property = "roleId", column = "ROLE_ID", id = true), //
			@Result(property = "name", column = "ROLE_NAME"), //
			@Result(property = "type", column = "ROLE_TYPE"), //
			@Result(property = "desc", column = "ROLE_DESC") }) //
	@Select("select * from roles where ROLE_ID in (${ids})")
	List<Role> findByRoleIds(@Param("ids") String ids);

}